﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Stp.Core
{
    public static class PluginFactory
    {
        public static dynamic GetPlugin(string currentPath, string assemblyName, string defaultNamespace, string targetName)
        {
            string plugin_fileLocation = currentPath + "\\" + assemblyName;

            Assembly plugin_Assembly = Assembly.LoadFile(plugin_fileLocation);
            Type plugin_Type = plugin_Assembly.GetType(defaultNamespace + "." + targetName);

            Type[] args = Type.EmptyTypes;
            ConstructorInfo ctro = plugin_Type.GetConstructor(args);

            return ctro.Invoke(new object[] { });
        }
    }
}
